package GO_BACK;

public class Player {
    private String name;
    private  int hp = 100;
    private Gun gun;

    public Player(String name, Gun gun) {
        this.name = name;
        this.gun = gun;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    public Gun getGun() {
        return gun;
    }

    public void setGun(Gun gun) {
        this.gun = gun;
    }

    public void hurt(Gun gun){
        this.hp -=gun.getDamage();
        if (hp>0){
            System.out.println("受到枪击,当前生命值为:"+this.hp);
            System.out.println("没死~~~哈哈哈");
        }else {
            System.out.println("挂了哦~");
        }
    }
    public void fire(Player player){
        if (player.gun == null){
            System.out.println("没枪!");
        }else if(player.gun.getBulletCount()==0){
            System.out.println("没子弹 ?@!#@!#");
        }else{
            System.out.println("FIRE!!!!@#!@$@");
        }

    }
}
